/**
 * @file MCU_WDT.c
 * @brief
 * @author F00
 * @date 2025-05-22
 */

#include "Common.h"
#include "stm32h7xx_hal.h"

IWDG_HandleTypeDef hiwdg1;

/**
 * @brief 初始化看门狗定时器，因为MCU擦除Flash时时间较长，所以需要设置合理的看门狗定时器时间
 *
 */
void MX_IWDG1_Init(void)
{
#if (OpenWDT == 1)
    hiwdg1.Instance = IWDG1;
    hiwdg1.Init.Prescaler = IWDG_PRESCALER_32;
    hiwdg1.Init.Window = 2000;
    hiwdg1.Init.Reload = 2000;
    if (HAL_IWDG_Init(&hiwdg1) != HAL_OK)
    {
        Error_Handler();
    }
#endif
}

void WDT_Feed(void)
{
#if (OpenWDT == 1)
    HAL_IWDG_Refresh(&hiwdg1);
#endif
}